package main.model.builder;

import java.text.ParseException;
import java.util.Map;
import main.controller.GEDIVAController;
import main.model.Company;
import main.model.Day;


/**
 * Builds a company!
 *
 * @author Kevin Gao
 *
 */
public class CompanyBuilder extends ModelBuilder {

    /**
     * Constructor for a new builder without a file type.
     *
     * @param controller The controller to register events with
     */
    public CompanyBuilder (GEDIVAController controller) {
        super(controller);
        flush();
    }

    @Override
    protected void buildFromParsed (Map<String, Object> data) throws ParseException {
        toModel().addRow(new Day(data));
    }

    @Override
    public void resetModel () {
        // initialize a new model
        setModel(new Company(getController()));
    }

    @Override
    public boolean canBuild (String type) {
        return "company".equalsIgnoreCase(type) || "market".equalsIgnoreCase(type);
    }

}
